package com.spzx.product.api;

import com.spzx.common.core.constant.SecurityConstants;
import com.spzx.common.core.constant.ServiceNameConstants;
import com.spzx.common.core.domain.R;
import com.spzx.common.core.web.page.TableDataInfo;
import com.spzx.product.domain.*;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@FeignClient(contextId = "remoteProductService",
		value = ServiceNameConstants.PRODUCT_SERVICE,
		fallbackFactory = RemoteProductFallbackFactory.class)
public interface RemoteProductService {

	@GetMapping("/product/getTopSale")
	public R<List<ProductSku>> getTopSale(@RequestHeader(SecurityConstants.FROM_SOURCE) String source);

	@GetMapping("/product/skuList/{pageNum}/{pageSize}")
	public R<TableDataInfo> skuList(@PathVariable("pageNum") Integer pageNum, @PathVariable("pageSize") Integer pageSize, @SpringQueryMap SkuQuery skuQuery, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

	@GetMapping("/product/getProductSku/{skuId}")
	public R<ProductSku> getProductSku(@PathVariable("skuId") Long skuId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

	@GetMapping(value = "/product/getProduct/{id}")
	public R<Product> getProduct(@PathVariable("id") Long id, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

	@GetMapping(value = "/product/getSkuPrice/{skuId}")
	public R<SkuPrice> getSkuPrice(@PathVariable("skuId") Long skuId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

	@GetMapping(value = "/product/getProductDetails/{id}")
	public R<ProductDetails> getProductDetails(@PathVariable("id") Long id, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

	@GetMapping(value = "/product/getSkuSpecValue/{id}")
	public R<Map<String, Long>> getSkuSpecValue(@PathVariable("id") Long id, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

	@GetMapping(value = "/product/getSkuStock/{skuId}")
	public R<SkuStockVo> getSkuStock(@PathVariable("skuId") Long skuId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

	@GetMapping(value = "/product/getSkuPriceList")
	R<List<SkuPrice>> getSkuPriceList(@RequestParam("skuIds") List<Long> skuIds, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

	@PostMapping("/product/checkAndLock/{orderNo}")
	R<String> checkAndLock(@PathVariable("orderNo") String orderNo,
						   @RequestBody List<SkuLockVo> skuLockVoList, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

	// @PostMapping("/product/unLockStock/{orderNo}")
	// void unLockStock(@RequestHeader(SecurityConstants.FROM_SOURCE) String source, @PathVariable String orderNo, @RequestBody List<SkuLockVo> skuLockVoList);
}
